home *** CD-ROM | disk | FTP | other *** search
/ Danny Amor's Online Library / Danny Amor's Online Library - Volume 1.iso / html / faqs / faq / x-faq / speedups < prev   
Encoding:
Text File  |  1995-07-25  |  31.7 KB  |  760 lines

  1. Subject: comp.windows.x: Getting more performance out of X.  FAQ
  2. Newsgroups: comp.windows.x,news.answers,comp.answers
  3. From: art@cs.ualberta.ca (Art Mulder)
  4. Date: 15 Nov 1994 16:11:47 GMT
  5.  
  6. Archive-name: x-faq/speedups
  7. Last-modified: 1994/10/17
  8.  
  9. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  10.     HOW TO MAXIMIZE THE PERFORMANCE OF X -- monthly posting
  11. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  12.         Compiled by Art Mulder (art@cs.ualberta.ca)
  13.  
  14.   More RAM, Faster CPU's, More disk space, Faster Ethernet....  These
  15.   are the standard responses you hear when you ask how to improve the
  16.   performance of your workstation.
  17.  
  18.   Well, more hardware isn't always an option, and I wonder if more
  19.   hardware is always even a necessity.
  20.  
  21.   This "FAQ" list is a collection of suggestions and ideas from
  22.   different people on the net on how you can the best possible
  23.   performance from X Windows on your workstation, WITHOUT PURCHASING
  24.   MORE HARDWARE.
  25.  
  26.   Performance is a highly subjective issue.  The individual user must
  27.   balance `speed' versus `features' in order to come to a personal
  28.   decision.  Therefore this document can be be expected to contain many
  29.   subjective opinions in and amongst the objective facts.
  30.  
  31.   This document is specifically concerned with X.  There are of course
  32.   many other factors that can affect the performance of a workstation.
  33.   However, they are outside the scope of this document.
  34.  
  35.     [ People seriously interested in the whole area of system
  36.     performance, might want to look at the O'Reilly Nutshell Handbook
  37.     "System Performance Tuning" by Mike Loukides.  IMHO, it contains a
  38.     well-written, comprehensive treatment of system performance.  I
  39.     refer to it a lot.  I'm unaware of any other similar books.  --ed.]
  40.  
  41. -----------------
  42. Table of Contents
  43. -----------------
  44.   0. Introduction & Administrivia
  45.   1. Window Managers
  46.   2. The X Server
  47.        Which Server?
  48.        Locking the Server into RAM?
  49.        Starting your Server
  50.        Fonts
  51.        About the Resources File
  52.        Define Your Display Properly
  53.   3. Clients
  54.        A Better Clock for X
  55.        A Better Terminal Emulator for X
  56.        Other Client Comments
  57.        Tuning your client
  58.   4. Miscellaneous Suggestions
  59.        Pretty Pictures
  60.        A Quicker Mouse
  61.        Programming Thoughts
  62.        Say What!?
  63.   5. Other Sources of Information
  64.        The "Other X FAQ"
  65.        Books & etc.
  66.   6. Author & Notes
  67.   
  68. ! = changed since last issue.
  69. * = new since last issue.
  70.  
  71. -----------------------------
  72. Introduction & Administrivia
  73. -----------------------------
  74.  
  75.   This document is posted each month, on or around the 15th, to the
  76.   Usenet news groups comp.windows.x, news.answers, and comp.answers.
  77.   If you are reading a copy of this FAQ which is more than a few
  78.   months old (see the "Last-modified" date above) you should probably
  79.   locate the latest edition, since the information may be outdated.
  80.  
  81.   If you do not know how to get those newsgroups and/or your site does
  82.   not receive them and/or this article has already expired, you can
  83.   retrieve this FAQ from an archive site.
  84.  
  85.   There exist several usenet FAQ archive sites.  To find out more about
  86.   them and how to access them, please see the "Introduction to the
  87.   *.answers newsgroups" posting in news.answers.
  88.  
  89.   The main FAQ archive is at rtfm.mit.edu.  This document can be found
  90.   there in /pub/usenet/news.answers/x-faq/speedups.  If you do not have
  91.   access to anonymous ftp, you can retrieve it by sending a mail
  92.   message to mail-server@rtfm.mit.edu with the command "send
  93.   usenet/news.answers/x-faq/speedups" in the message body.
  94.  
  95.   In addition, this FAQ is available at ftp.x.org (and it's mirror
  96.   sites) in /contrib/faqs/speedup-x-faq.  Most X FAQs are there.
  97.  
  98. ---------------
  99. Window Managers
  100. ---------------
  101.  
  102.   There are a lot of window managers out there, with lots of different
  103.   features and abilities.  The choice of which to use is by necessity a
  104.   balancing act between performance and useful features.  At this
  105.   point, most respondents have agreed upon "twm" as the best candidate
  106.   for a speedy window manager. 
  107.  
  108.   A couple of generic tricks you can try to soup up your window manger,
  109.   is turning off unnecessary things like "zooming" and "opaque move".
  110.   Also, if you lay out your windows in a tiled manner, you reduce the
  111.   amount of cpu power spent in raising and lowering overlapping
  112.   windows.                           Joe English (joe@trystero.art.com)
  113.  
  114.   I've found that a good font for tiling is 7x13 (aka:
  115.   -misc-fixed-medium-r-normal--13-100-100-100-c-70-iso8859-1 ). It is
  116.   the biggest font I know of that I can use on my Sun (1152x900 screen)
  117.   and still get two 80 column terminal windows side-by-side on the
  118.   display with no overlap.  Other font suggestions will be accepted.
  119.  
  120. Suggestions for your consideration:
  121.  
  122.   Linux'ers and others might want a look at fvwm.  A light-weight
  123.   virtual wm, targeted at ``machines with too little memory, at laptops
  124.   on which mouse usage may be awkward, and at users who prefer the
  125.   appearance of the Motif window manager to twm ... all wm functions
  126.   can be performed w/out a mouse'' [from the README].
  127.                                    Zack Evans (zevans@nyx.cs.du.edu)
  128.  
  129.   While originally developed for Linux, fvwm will compile on a number
  130.   of different platforms.  The fvwm docs claim a memory consumption of
  131.   about 1/3 to 2/3 that of twm.
  132.  
  133. ------------ 
  134. The X Server
  135. ------------
  136.  
  137. Which Server?
  138. - - - - - - -
  139.   Make sure that your server is a proper match for your hardware.
  140.   If you have a monochrome monitor, use a monochrome X11 server.
  141.  
  142.   On my Monochrome Sun, I haven't noticed much difference between
  143.   the Xsun (colour) server and XsunMono, however it was pointed out to
  144.   me that XsunMono is about 800k smaller and therefore should contribute
  145.   to less paging.  
  146.          [ thanks to: Jonny Farringdon (j.farringdon@psychol.ucl.ac.uk),
  147.                         Michael Salmon (Michael.Salmon@eos.ericsson.se) ]
  148.  
  149.   How your server was compiled can also make a difference.  Jeff Law
  150.   (law@schirf.cs.utah.edu) advises us that on a Sun system, X should be
  151.   compiled with gcc (version 2.*) or with the unbundled Sun compiler.
  152.   You can expect to get "*very* large speedups in the server" by not
  153.   using the bundled SunOS compiler.  I assume that similar results
  154.   would occur if you used one of the other high-quality commercial
  155.   compilers on the market.
  156.  
  157. Locking the Server into RAM?
  158. - - - - - - - - - - - - - - -
  159.   It was suggested that perhaps hacking the X server so that it would
  160.   stay locked in RAM (and therefore not get paged out) might help
  161.   performances.  eg: via a call to plock().
  162.        [Eric C Claeys (ecc@eperm.att.com), Danny Backx (db@sunbim.be),
  163.     Juan D. Martin (juando@cnm.us.es)]
  164.  
  165.   Kenny Ranerup [kenny@axis.se] tried this a few years ago and
  166.   confirmed that it does work, and can give a noticeable speedup.  But,
  167.   you must be careful that your server doesn't grow too large (ie,
  168.   close to the size of your RAM).  He also makes the point that slow
  169.   interactive performace is in many cases due to client paging (paging
  170.   in libraries), and not server paging.
  171.  
  172. Starting your Server
  173. - - - - - - - - - - -
  174.   Joe English (joe@trystero.art.com) :
  175.     If you start up a lot of clients in your .xsession or whatever, sleep
  176.     for a second or two after launching each one.  After I changed my
  177.     .xclients script to do this, logging in actually took *less* time...
  178.     we have a heavily loaded system without much core, though.
  179.  
  180.   This sounds crazy, but I have confirmed that it works!  
  181.  
  182.   Warner Losh (imp@Boulder.ParcPlace.COM) provided me with a good
  183.   explanation of why this works, which I have summarized here:
  184.  
  185.     When you start up an X server it takes a huge amount of time to
  186.     start accepting connections.  A lot of initialization is done by
  187.     the server when it starts.  This process touches a large number of
  188.     pages.  Any other process running at the same time would fight the
  189.     server for use of the CPU, and more importantly, memory.  If you
  190.     put a sleep in there, you give the Server a chance to get itself
  191.     sorted out before the clients start up.
  192.  
  193.     Similarly, there is also a lot of initialization whenever an X
  194.     client program starts: toolkits registering widgets, resources
  195.     being fetched, programs initializing state and "databases" and so
  196.     forth.  All this activity is typically memory intensive.  Once this
  197.     initialization is done ("The process has reached a steady state"),
  198.     the memory usage typically settles down to using only a few pages.
  199.     By using sleeps to stagger the launching of your clients in your
  200.     .Xinitrc , you avoid them fighting each other for your
  201.     workstation's limited resources
  202.  
  203.   This is most definitely a "Your Mileage May Vary" situation, as there
  204.   are so many variables to be considered: available RAM, local swap
  205.   space, load average, number of users on your system, which clients
  206.   you are starting, etc.
  207.  
  208.   Currently in my .xinitrc I have a situation like:
  209.     (sleep 1; exec xclock ) &
  210.     (sleep 1; exec xbiff ) &
  211.     (sleep 1; exec xterm ) &
  212.     (sleep 1; exec xterm ) &
  213.  
  214.   I've experimented with:
  215.     (sleep 1; exec xclock ) &
  216.     (sleep 2; exec xbiff ) &
  217.     (sleep 3; exec xterm ) &
  218.     (sleep 4; exec xterm ) &
  219.  
  220.   I've even tried:
  221.     (sleep 2; exec start_X_clients_script ) &
  222.   and then in start_X_clients_script I had:
  223.     (sleep 1; exec xclock ) &
  224.     (sleep 1; exec xbiff ) &
  225.     (sleep 1; exec xterm ) &
  226.     (sleep 1; exec xterm ) &
  227.  
  228.     [ The idea with this last one was to make sure that xinit had
  229.     completely finished processing my .xinitrc, and had settled down
  230.     into a "steady state" before the sleep expired and all my clients
  231.     were launched. ]
  232.  
  233.   All of these yielded fairly comparable results, and so I just stuck
  234.   with my current setup, for its simplicity.  You will probably have to
  235.   experiment a bit to find a setup which suits you.
  236.  
  237. Fonts
  238. - - -
  239.   Loading fonts takes time and RAM.  If you minimize the number of fonts
  240.   your applications use, you'll get speed increases in load-up time.
  241.  
  242.   One simple strategy is to choose a small number of fonts (one small,
  243.   one large, one roman, whatever suits you) and configure all your
  244.   clients -- or at least all your heavily used clients -- to use only
  245.   those few fonts.  Client programs should start up quicker if their
  246.   font is already loaded into the server.  This will also conserve
  247.   server resources, since fewer fonts will be loaded by the server.
  248.                   [ Farrell McKay (fbm@ptcburp.ptcbu.oz.au),
  249.                     Joe English (joe@trystero.art.com) ]
  250.  
  251.   eg: My main xterm font is 7x13, so I also have twm set up to use 7x13
  252.   in all it's menus and icons etc.  Twm's default font is 8x13.  Since
  253.   I don't normally use 8x13, I've eliminated one font from my server.
  254.  
  255.   Oliver Jones (oj@roadrunner.pictel.com):
  256.     Keep fonts local to the workstation, rather than loading them over nfs.
  257.     If you will make extensive use of R5 scalable fonts, use a font server.
  258.  
  259. About the Resources File
  260. - - - - - - - - - - - - -
  261.  
  262.     Keep your .Xresources / .Xdefaults file small.  Saves RAM and saves
  263.     on server startup time.          Joe English (joe@trystero.art.com)
  264.  
  265.   One suggestion:
  266.  
  267.     In your .Xresources file, try putting only the minimum number of
  268.     resources that you want to have available to all of your
  269.     applications.  For example:  *reverseVideo: true
  270.  
  271.     Then, separate your resources into individual client-specific
  272.     resource files.  For example: $HOME/lib/app-defaults.  In your
  273.     .login file set the environment variable XUSERFILESEARCHPATH:
  274.  
  275.     setenv XUSERFILESEARCHPATH $HOME/lib/app-defaults/%N
  276.  
  277.     (Note:  It is easier and quicker for Xt to process
  278.     XUSERFILESEARCHPATH than XAPPLRESDIR.)
  279.  
  280.     [ The "comp.windows.x Frequently Asked Questions" FAQ contains
  281.     an excellent explanation of how this and the other main X
  282.     environment variables work.  --ed.]
  283.  
  284.     So, when xterm launches, it loads (through Xt) its resources from
  285.     .../app-defaults/XTerm.  Xdvi finds them in .../app-defaults/XDvi,
  286.     and so on and so forth.  Note that not all clients follow the same
  287.     XXxxx resource-file naming pattern.  You can check in your system
  288.     app-defaults directory (often: /usr/X11R5/lib/X11/app-defaults/) to
  289.     find the proper name, and then name your personal resource files
  290.     with the same name.
  291.  
  292.     This is all documented in the Xt Specification (pg 125 & 666).
  293.             [Thanks to: Kevin Samborn (samborn@mtkgc.com),
  294.                  Michael Urban (urban@cobra.jpl.nasa.gov),
  295.              Tom Bagli (tomb@gator.bocaraton.ibm.com),
  296.                      and Mike Long (mikel@ee.cornell.edu).
  297.          Kevin is willing mail his setup files to inquirers.]
  298.  
  299.   This method of organizing your personal resources has the following
  300.   benefits:
  301.  
  302.     - Easier to maintain / more usable.
  303.  
  304.     - Fewer resources are stored in the X server in the RESOURCE_MANAGER
  305.       property.  As a side benefit your server may start fractionally
  306.       quicker, since it doesn`t have to load all your resources.
  307.  
  308.     - Applications only process their own resources, never have to sort
  309.       through all of your resources to find the ones that affect them.
  310.  
  311.   It also has drawbacks:
  312.  
  313.     - the application that you are interested in has to load an
  314.       additional file every time it starts up.  This doesn't seem to
  315.       make that much of a performance difference, and you might
  316.       consider this a huge boon to usability.  If you are modifying an
  317.       application's resource database, you just need to re-run the
  318.       application without having to "xrdb" again.
  319.  
  320.     - xrdb will by default run your .Xresources file through cpp.  When
  321.       your resources are split out into multiple resource files and
  322.       then loaded by the individual client programs, they will not.
  323.       WATCH OUT FOR THIS!!
  324.  
  325.       I had C style comments in my .Xresources file, which cpp stripped
  326.       out.  When I switched to this method of distributed resource
  327.       files I spent several frustrating days trying to figure out why
  328.       my clients were not finding their resources.  Xt did *NOT*
  329.       provide any error message when it encountered the C style
  330.       comments in the resource files, it simply, silently, aborted
  331.       processing the resource file.
  332.  
  333.       The loss of preprocessing (which can be very handy, e.g. ``#ifdef
  334.       COLOR'' ...) is enough to cause some people to dismiss this
  335.       method of resource management.
  336.  
  337.     - You may also run into some clients which "break the rules".  For
  338.       example, neither Emacs (18.58.3) nor Xvt (1.0) will find their
  339.       resources if they are anywhere other than in .Xresources.
  340.  
  341.       This is because emacs (and presumably, Xvt) are not Xt based
  342.       applications.  They are coded to use Xlib directly.
  343.       XUSERFILESEARCHPATH and XAPPLRESDIR are Xt features.
  344.                  Larry Williamson (larry@witch.mitra.com)
  345.  
  346.     - when starting up a client on a machine that does not share files
  347.       with the machine where your resources are stored, your client
  348.       will not find its resources.  Loading all your resources into the
  349.       server will guarantee that all of your clients will always find
  350.       their resources.            Casey Leedom (casey@gauss.llnl.gov)
  351.  
  352.   A possible compromise that I have tried, is to put resources for all
  353.   my heavily used clients (eg: xterm) into my .Xresources file, and to
  354.   use the "separate resources files" method for clients that I seldom
  355.   use.
  356.  
  357. Define Your Display Properly
  358. - - - - - - - - - - - - - - -
  359.  
  360.   Client programs are often executed on the same machine as the
  361.   server.  In that situation, rather than setting your DISPLAY
  362.   environment variable to "<hostname>:0.0", where <hostname> is the
  363.   name of your workstation, you should set your DISPLAY variable to
  364.   "unix:0.0" or ":0.0".  By doing this you access optimized routines
  365.   that know that the server is on the same machine and use a shared
  366.   memory method of transferring requests.
  367.             [thanks to Patrick J Horgan (pjh70@ras.amdahl.com)]
  368.  
  369.   See the _DISPLAY NAMES_ section of the X(1) man page for further
  370.   explanation of how to properly set your display name.
  371.  
  372.   "I don't think it's stock MIT, but (at least) Data General and HP
  373.   have libraries that are smart enough to use local communication even
  374.   when the DISPLAY isn't set specially."
  375.                   Rob Sartin (88opensi!sartin@uunet.UU.NET)
  376.  
  377.   [Jody Goldberg (jody@algorithmics.com) sent me an Xlib patch to
  378.   change stock R5 to use local communication even if DISPLAY is not
  379.   properly set.  I don't want to get in the business of distributing or
  380.   trying to juggle non-MIT patches and so have elected not to include
  381.   it here.  Hopefully MIT will apply this minor (~8 lines) patch
  382.   themselves.  In the meantime, if you want to try it yourself, email
  383.   Jody.  --ed.]
  384.  
  385. -------
  386. Clients
  387. -------
  388.  
  389.   If you only have a few megabytes of Ram then you should think
  390.   carefully about the number of programs you are running.  Think also
  391.   about the _kind_ of programs you are running.  For example:  Is there
  392.   a smaller clock program than xclock?
  393.  
  394.   Unfortunately, I haven't really noticed that programs advertise how
  395.   large they are, so the onus is on us to do the research and spread
  396.   the word.
  397.  
  398.   [ Suggestions on better alternatives to the some of the standard
  399.   clients (eg: Xclock, Xterm, Xbiff) are welcome.  --ed.]
  400.  
  401.   I've received some contradictory advice from people, on the subject
  402.   of X client programs.  Some advocate the use of programs that are
  403.   strictly Xlib based, since Xt, Xaw and other toolkits are rather
  404.   large.  Others warn us that other applications which you are using
  405.   may have already loaded up one or more of these shared libraries.  In
  406.   this case, using a non-Xt (for example) client program may actually
  407.   _increase_ the amount of RAM consumed.
  408.  
  409.   The upshot of all this seems to be: Don't mix toolkits.  That is, try
  410.   and use just Athena clients, or just Xview clients (or just Motif
  411.   clients, etc).  If you use more than one, then you're dragging in
  412.   more than one toolkit library.
  413.  
  414.   Know your environment, and think carefully about which client
  415.   programs would work best together in that environment.
  416.  
  417.         [Thanks to: Rob Sartin (88opensi!sartin@uunet.UU.NET),
  418.     Duncan Sinclair (sinclair@dcs.gla.ac.uk | sinclair@uk.ac.gla.dcs) ]
  419.  
  420. A Better Clock for X
  421. - - - - - - - - - - -
  422.  
  423. 1) xcuckoo
  424.    suggested by: Duncan Sinclair (sinclair@dcs.gla.ac.uk)
  425.    available: on export.lcs.mit.edu
  426.  
  427.    Xcuckoo displays a clock in the title bar of *another* program.
  428.    Saves screen real estate.
  429.  
  430. 2) mclock
  431.    suggested by: der Mouse (mouse@Lightning.McRCIM.McGill.EDU)
  432.    available: larry.mcrcim.mcgill.edu (132.206.1.1) in /X/mclock.shar
  433.  
  434.    Non Xt-based.  Extensively configurable.  it can be made to look
  435.    very much like MIT oclock, or mostly like xclock purely by changing
  436.    resources.
  437.  
  438.   Of course, the ultimate clock --- one that consumes no resources, and 
  439.   takes up no screen real estate --- is the one that hangs on your wall.
  440.   :-) 
  441.  
  442. A Better Terminal Emulator for X
  443. - - - - - - - - - - - - - - - - -
  444.  
  445.   From the README file distributed with xterm:
  446.  
  447.   +-----
  448.   |         Abandon All Hope, Ye Who Enter Here
  449.   |
  450.   | This is undoubtedly the most ugly program in the distribution.
  451.   | ...
  452.   +-----
  453.  
  454.   Ugly maybe, but at my site it's still the most used.  I suspect that
  455.   xterm is one of the most used clients at many, if not most sites.
  456.   Laziness?  Isn't there a better terminal emulator available?  See
  457.   below.
  458.  
  459.   If you must use xterm, you can try reducing the number of saveLines
  460.   to reduce memory usage.  [ Oliver Jones (oj@roadrunner.pictel.com),
  461.            Jonny Farringdon (j.farringdon@psychol.ucl.ac.uk) ]
  462.  
  463. 1) Xvt
  464.    Suggested by: Richard Hesketh (rlh2@ukc.ac.uk)
  465.    Author: John D. Bovey (jdb@ukc.ac.uk)
  466.    Available: export.lcs.mit.edu in /contrib/xvt-1.0.tar.Z
  467.  
  468.    [From the README file] "Xvt is an X terminal-emulator that is
  469.    designed to be more or less compatible with xterm while using much
  470.    less swap space.  It is mainly intended for use at sites which use
  471.    large numbers of X terminals but may also be useful on single
  472.    workstations that are short of memory.  On a [SunOS 4.1.* Sparc], an
  473.    initially invoked xvt uses about 1/3 megabyte of swap while xterm
  474.    uses about 1.3 megabytes (obtained by running pstat rather than ps
  475.    which seems to give unreliable size figures on SPARCs).  The main
  476.    way that xvt achieves its small size is by avoiding the use of the X
  477.    toolkit."
  478.  
  479.    Since it is a partial 'clone' of xterm, you don't have to rename
  480.    your resources, as xvt pretends to be "XTerm".  In it's current
  481.    version, you cannot bind keys as you can in xterm.  I've heard that
  482.    there are versions of xvt with this feature, but I've not found any
  483.    yet.
  484.  
  485.    UPDATE (Oct 1993):  John Bovey tells me that a new version of xvt is
  486.    in the works that should have some of the most frequently missed
  487.    xterm features.
  488.  
  489.    There have been some conflicting opinions aired over xvt vs. xterm.
  490.    Different sites with different needs will likely have to do
  491.    their own evaluation.  Caveat Emptor, your mileage may vary.
  492.  
  493.    I have seen hard data from J.Bovey showing how xvt does in fact
  494.    require less swap space than xterm.  However, both of us would still
  495.    like to see any other benchmarks that people can provide comparing
  496.    the two.  (eg: How much RAM each occupies, relative speed of each.)
  497.  
  498. 2) rxvt
  499.    Suggested by: Zack Evans (zevans@nyx.cs.du.edu)
  500.    Author: Rob Nation (nation@rocket.sanders.lockheed.com)
  501.  
  502.    Apparently a stripped down Linux port of xvt, with some 
  503.    minor modifications. 
  504.  
  505. 3) mterm
  506.    Suggested by/Author: der Mouse (mouse@Lightning.McRCIM.McGill.EDU)
  507.    Available: larry.mcrcim.mcgill.edu (132.206.1.1) in
  508.      /X/mterm.src/mterm.ball-o-wax.
  509.  
  510.    "I also have my own terminal emulator.  Its major lack is
  511.    scrollback, but some people like it anyway."
  512.  
  513. Other Client Comments
  514. - - - - - - - - - - -
  515.   When using the xlock screen locking client, the "qix" mode is
  516.   much more lightweight than the default mode.  
  517.                  [Q. Alex Zhao (azhao@cc.gatech.edu)]
  518.  
  519.   I can confirm the previous report from personal experience  here.  In
  520.   a lab full of ~20 sun 3/80's all running the Xkernel software, the
  521.   subnet was getting regularly clobbered.  This was tracked down to
  522.   students running xlock.  Since these machines are all xterminals, the
  523.   actual xlock program runs remotely, and generates a scary amount of
  524.   network traffic to draw the default 'swarm' pictures on the screen.
  525.   We have removed this program and replaced it with a much simpler
  526.   screen locking program which simply blanks the screen.        [ed.]
  527.  
  528.   A suggestion: xtrlock, by Ian Jackson <ijackson@nyx.cs.du.edu>
  529.   It is very small (about 16k running), and doesn't produce any traffic
  530.   while locked. Drawback: It doesn't make your screen invisible.
  531.               [ Klamer Schutte (klamer@ph.tn.tudelft.nl) ]
  532.  
  533.   An improved xbiff: Xbuffy.  It can watch multiple mailboxes and can
  534.   do a pop up showing the From and Subject line of incoming mail.
  535.   Xbiff doesn't eat much memory and Xbuffy tends to be about the same
  536.   (on the RS/6000, xbuffy tends use just a little less memory).  It is
  537.   in the contrib directory on ftp.x.org.
  538.                                [ Bill Pemberton (wfp5p@virginia.edu) ]
  539.  
  540. Tuning your client
  541. - - - - - - - - - -
  542.  
  543.   Suggestions on how you can tune your client programs to work faster.
  544.  
  545.   From Scott Barman (scott@asd.com) comes a suggestion regarding Motif
  546.   Text Field Widgets:
  547.  
  548.     I noticed that during data entry into Motif text field widgets, I
  549.     was getting a slight lag in response to some keystrokes,
  550.     particularly the initial one in the field.  Examining the what was
  551.     going on with xscope I found it.  It seems that when the resource
  552.     XmNblinkRate is non-zero and the focus is on a text field widget
  553.     (or even just a text widget) the I-beam cursor will blink.  Every
  554.     time the cursor appears or disappears in those widgets, the widget
  555.     code is making a request to the server (CopyArea).  The user can
  556.     stop this by setting the resource XmNblinkRate to 0.  It is not
  557.     noticeable on a 40MHz SPARC, but it does make a little difference
  558.     on a [slower system].
  559.  
  560.   This specific suggestion can probably be applied in general to lots
  561.   of areas.  Consider your heavily used clients, are there any minor
  562.   embellishments that can be turned off and thereby save on Server
  563.   requests?
  564.  
  565. -------------------------
  566. Miscellaneous Suggestions
  567. -------------------------
  568.  
  569. Pretty Pictures
  570. - - - - - - - -
  571.   Don't use large bitmaps (GIF's, etc) as root window backgrounds.
  572.  
  573.   - The more complicated your root window bitmap, the slower the server
  574.     is at redrawing your screen when you reposition windows (or redraw,
  575.     etc)
  576.  
  577.   - These take up RAM, and CPU power.  I work on a Sun SPARC and I'm
  578.     conscious of performance issues, I can't comprehend it when I see
  579.     people with a 4mb Sun 3/60 running xphoon as their root window.
  580.  
  581.     I'll let someone else figure out how much RAM would be occupied by
  582.     having a full screen root image on a colour workstation.
  583.  
  584.   - If you're anything like me, you need all the screen real estate
  585.     that you can get for clients, and so rarely see the root window
  586.     anyway.
  587.  
  588.               [ Thanks to Qiang Alex Zhao (azhao@cs.arizona.edu) 
  589.             for reminding me of this one. --ed.]
  590.  
  591. A Quicker Mouse
  592. - - - - - - - -
  593.   Using xset, you can adjust how fast your pointer moves on the screen
  594.   when you move your mouse.  I use "xset m 3 10" in my .xinitrc file,
  595.   which lets me send my pointer across the screen with just a flick of
  596.   the wrist.  See the xset man page for further ideas and information.
  597.  
  598.   Hint: sometimes you may want to *slow down* your mouse tracking for
  599.   fine work.  To cover my options, I have placed a number of different
  600.   mouse setting commands into a menu in my window manager.  
  601.  
  602.   e.g. (for twm) :
  603.       menu "mouse settings" {
  604.         "Mouse Settings:"            f.title
  605.     "  Very Fast"                ! "xset m 7 10 &"
  606.     "  Normal (Fast)"            ! "xset m 3 10 &"
  607.     "  System Default (Un-Accelerated)"    ! "xset m default &"
  608.     "  Glacial"                ! "xset m 0 10 &"
  609.       }
  610.  
  611. Programming Thoughts
  612. - - - - - - - - - - -
  613.   Joe English (joe@trystero.art.com) :
  614.     To speed up applications that you're developing, there are tons of
  615.     things you can do.  Some that stick out:
  616.  
  617.     - For Motif programs, don't set XmFontList resources for individual
  618.       buttons, labels, lists, et. al.; use the defaultFontList or
  619.       labelFontList or whatever resource of the highest-level manager
  620.       widget.  Again, stick to as few fonts as possible.
  621.  
  622.     - Better yet, don't use Motif at all.  It's an absolute pig.
  623.  
  624.     - Don't create and destroy widgets on the fly.  Try to reuse them.
  625.       (This will avoid many problems with buggy toolkits, too.)
  626.  
  627.     - Use a line width of 0 in GCs.  On some servers this makes a HUGE
  628.       difference.
  629.  
  630.     - Compress and collapse multiple Expose events.  This can make the
  631.       difference between a fast application and a completely unusable
  632.       one.
  633.  
  634.   Francois Staes (frans@kiwi.uia.ac.be) :
  635.     Just a small remark: I once heard that using a better malloc
  636.     function would greatly increase performance of Xt based
  637.     applications since they use malloc heavily. They suggested trying
  638.     out the GNUY malloc, but I didn't find the time yet. I did some
  639.     tests on small programs just doing malloc and free, and the
  640.     differences were indeed very noticeable ( somewhat 5 times faster)
  641.  
  642.   [ Any confirmation on this from anyone?  --ed.]
  643.  
  644.   Andre' Beck (Andre_Beck@IRS.Inf.TU-Dresden.de) :
  645.  
  646.   - Unnecessary NoExpose Events.
  647.  
  648.     Most people use XCopyArea/XCopyPlane as fastest blit routines, but
  649.     they forget to reset graphics_exposures in the GC used for the
  650.     blits. This will cause a NoExpose Event every blit, that, in most
  651.     cases, only puts load onto the connection and forces the client to
  652.     run through it's event-loop again and again.
  653.  
  654.   - Thousands of XChangeGC requests.
  655.  
  656.     This "Gfx Context Switching" is also seen in most handcoded X-Apps,
  657.     where only one or few GCs are created and then heavily changed
  658.     again and again.  Xt uses a definitely better mechanism, by caching
  659.     and sharing a lot of GCs with all needed parameters. This will
  660.     remove the load of subsequent XChangeGC requests from the
  661.     connection (by moving it toward the client startup phase).
  662.  
  663. Say What!?
  664. - - - - - - 
  665.   Some contributors proposed ideas that seem right off the wall at first:
  666.  
  667.   David B. Lewis (by day: dbl@osf.org, by night: david%craft@uunet.uu.net) :
  668.     How about this: swap displays with someone else. Run all your
  669.     programs on the other machine and display locally; the other user
  670.     runs off your machine onto the other display. Goal: reduce context
  671.     switches in the same operation between client and server.
  672.  
  673.   I'm not in a situation where I can easily try this, but I have
  674.   received the following confirmation...
  675.  
  676.   Michael Salmon (Michael.Salmon@eos.ericsson.se):
  677.     I regularly run programs on other machines and I notice a big
  678.     difference. I try to run on a machine where I will reduce net usage
  679.     and usually with nice to reduce the impact of my intrusion. This
  680.     helps a lot on my poor little SS1+ with only 16 MB, it was
  681.     essential when I only had 8 MB.
  682.  
  683.   Casey Leedom (casey@gauss.llnl.gov) :
  684.     [The X11 Server and the client are] competing for the same CPU as
  685.     your server when you run it on the same machine.  Not really a
  686.     major problem, except that the X11 client and the server are in
  687.     absolute synchronicity and are context thrashing.
  688.  
  689.   Timothy H Panton (thp@westhawk.uucp) :
  690.     Firstly it relies on the fact that most CPU's are mostly idle, X's
  691.     cpu usage is bursty.  so the chances of you and your teammate
  692.     doing something cpu-intensive at the same time is small. If they
  693.     are not then you get twice the cpu+memory available for your
  694.     action.
  695.  
  696.     The second factor is that context switches are expensive, using 2
  697.     cpu's halves them, you pay a price due to the overhead of going
  698.     over the network, but this is offset in most cases by the improved
  699.     buffering of a network (typically 20k vs 4k for a pipe), allowing
  700.     even fewer context switches.
  701.  
  702. ----------------------------
  703. Other Sources of Information
  704. ----------------------------
  705.  
  706. The "Other X FAQ"
  707. - - - - - - - - -
  708.  
  709.   David B. Lewis (faq%craft@uunet.uu.net) maintains the informative and
  710.   well written "comp.windows.x Frequently Asked Questions" document.
  711.   Its focus is on general X information, while this FAQ concentrates
  712.   on performance.
  713.  
  714.   The comp.windows.x FAQ does address the issue of speed, but only with
  715.   regards to the X server.  The gist of that topic seems to be:
  716.     "Use X11R5, it is faster than R4".
  717.   (Please see the X FAQ for complete details).
  718.  
  719. Books & etc.
  720. - - - - - - -
  721.  
  722.   Volume 8 in O'Reilly's X Window System Series; ``X Window System
  723.   Administrator's Guide'' is a book that all X administrator's should
  724.   read.  (email your snailmail address to catalog@ora.com for a catalog)
  725.  
  726.   Adrian Nye (adrian@ora.com):
  727.     A lot more tips on performance are in the paper "Improving X
  728.     Application Performance" by Chris D. Peterson and Sharon Chang, in
  729.     Issue 3 of The X Resource.
  730.  
  731.     An earlier version of this paper appeared in the Xhibition 1992
  732.     conference proceedings.
  733.  
  734.     This paper is absolutely essential reading for X programmers.
  735.   [For information on The X Resource, contact paula@ora.com --ed.]
  736.  
  737. --------------
  738. Author & Notes
  739. --------------
  740.   This list is currently maintained by Art Mulder (art@cs.ualberta.ca)
  741.  
  742.   Suggestions, corrections, or submission for inclusion in this list
  743.   are gladly accepted.  Layout suggestions and comments (spelling
  744.   mistak's too! :-) are also welcome.
  745.  
  746.   Currently I have listed all contributors of the various comments and
  747.   suggestions.  If you do not want to be credited, please tell me.
  748.  
  749.   speedup-x-faq is copyright (c) 1993 by Arthur E. Mulder
  750.  
  751.   You may copy this document in whole or in part as long as you don't
  752.   try to make money off it, or pretend that you wrote it.
  753.  
  754. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  755. --
  756.  ...art mulder ( art@cs.ualberta.ca )    | "Do not be conformed to this world,
  757.  http://web.cs.ualberta.ca/~art/         |  but be transformed by the renewal
  758.  CS Dept, U of Alberta, Edmonton, Canada |  of your mind, ..."  Romans 12:2
  759.  
  760.